import {
  Column,
  Entity,
  JoinColumn,
  JoinTable,
  ManyToMany,
  PrimaryGeneratedColumn,
  OneToMany,
} from 'typeorm';
import { Authority } from '../../authority/entities/authority.entity';
import { UsersEntity } from '../../users/users.entity';

@Entity()
export class Role {
  @PrimaryGeneratedColumn()
  id: number;

  @Column({ length: 500 })
  name: string;

  @Column('text', { nullable: true })
  desc: string;

  @Column()
  code: string;

  /*  @ManyToMany(type => Authority, authority => authority.roles)
  @JoinTable()
  authority: Authority[];*/

  @OneToMany(() => UsersEntity, (user) => user.role)
  users: UsersEntity[];

  @ManyToMany((type) => Authority, (authority) => authority.roles)
  @JoinTable()
  authority: Authority[];

  @Column({ default: '', nullable: true })
  crateTime: string;

  @Column({ default: '', nullable: true })
  updateTime: string;

  @Column({ default: '', nullable: true })
  deleteTime: string;
}
